
export const filterLayersById=function (layerschoosearr,layersconf) {
    return layersconf.filter((item)=>{ //将图层配置中的图层符合此功能的过滤出来
        return layerschoosearr.some((id)=>{
            return id === item.id
        })
    })
}

export const getObjectKeys = function (obj) { //获取对象的键值
    return Object.keys(obj).map((key)=>{
        return key
    })
}

function dynamicUniqueRenderer(field,symbols,defualtSymbol) {
    let uniqueInfos = symbols.filter((item)=>{
        let symb =item.symbol.split(',');
        return {
            value:item.symbolid,
            symbol:{
                type: "simple-fill",
                color: [symb[0],symb[1],symb[2],symb[3]]
            }
        }
    })

    return {
        type: "unique-value",
        field: field,
        defaultSymbol: defualtSymbol?defualtSymbol:{},
        uniqueValueInfos:uniqueInfos
    }
}

function getTextSymbol(text){
  return {
    type: "text",
    color: [0, 0, 255, 1],
    haloColor: [255, 255, 255, 1],
    haloSize: "2px",
    text: text,
    xoffset: 3,
    yoffset: 3,
    font: {
      size: 16,
      family: "fangsong",
      weight: "bold"
    }
  };
}

function getLabelingInfo(field,color,fontsize){
  return[{
    labelExpression: "["+field+"]",
    labelPlacement: "always-horizontal",
    symbol: {
      type: "text",
      color: color|[9, 47, 134,],
      haloColor: [248, 248, 248, 0.85],
      haloSize: fontsize|1,
      font: {
        size: 14,
        weight: "bolder",
      }
    },
  }]
}

function loadGraphics(pointArr,sym){
  return pointArr.map((item)=>{
    return {
      geometry:{
        type:'point',
        longitude:item.longitude,
        latitude:item.latitude
      },
      attributes:item,
      symbol:sym
    }
  })
}

let renderers = {
    

}

export const reWriteLayersConfig = function (layerschoosearr,layersconf) {
    let funConfig = filterLayersById(layerschoosearr,layersconf);
    return funConfig.map((item)=>{
        item.renderers = renderers[item.id]
        return item
    })
}

export const visLayers = [1,2,3,4,5,6,7,8,9,10,11]